# Maintainer: Orhun Parmaksız <orhun@archlinux.org>
# Contributor: CosmicHorror <LovecraftianHorror@pm.me>

pkgname=cargo-auditable
pkgver=0.6.1
pkgrel=1
pkgdesc="A cargo-subcommand to make production Rust binaries auditable"
arch=('loong64' 'x86_64')
url="https://github.com/rust-secure-code/cargo-auditable"
license=('Apache' 'MIT')
depends=('gcc-libs')
makedepends=('cargo')
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz"
        "$pkgname-$pkgver-cargo-lock.patch::$url/commit/5638b5803c744f1da2e8e24a4ff03d0a5e9920bd.patch")
sha512sums=('191b6ef15436bd3c6a9b4666e80de5a085afe00f8ee3793040fc5e5f78eecc25d45e556fe8279b600f362b46cbecae6c6f7e21060ea0d2344f459817749f4616'
            '0e376830391c7e8c7ba645e8cfe4240297701ece81a813c53c8f2a345d1d93524ee1c423cb8c8d21c7ab4d251c480f517ab61dcd4eb44cd6c6ac20daa474b262')

prepare() {
  cd "$srcdir/$pkgname-$pkgver"
  patch -Np1 -i "../$pkgname-$pkgver-cargo-lock.patch"
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "$srcdir/$pkgname-$pkgver"
  cargo build --release --frozen
}

check() {
  cd "$srcdir/$pkgname-$pkgver"
  cargo test --frozen
}

package() {
  cd "$srcdir/$pkgname-$pkgver"
  install -Dm755 "target/release/$pkgname" "$pkgdir/usr/bin/$pkgname"
  install -Dm644 LICENSE-MIT -t "$pkgdir/usr/share/licenses/$pkgname"
  install -Dm644 README.md -t "$pkgdir/usr/share/doc/$pkgname"
  install -Dm644 "$pkgname/$pkgname.1" -t "$pkgdir/usr/share/man/man1"
}

# vim: ts=2 sw=2 et:
